package jmine.tec.persist.schema.embedded.list;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import jmine.tec.persist.annotation.Alias;
import jmine.tec.persist.annotation.Comment;
import jmine.tec.persist.annotation.Comments;
import jmine.tec.persist.annotation.Index;
import jmine.tec.persist.annotation.Indexes;
import jmine.tec.persist.schema.embedded.EmbeddedField;

import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.IndexColumn;

import bancosys.tec.component.Documentation;
import bancosys.tec.persist.bussobj.PersistableBusinessObject;

@Entity
@Alias("EMBEDD")
@Table(name = "EMBEDDED")
@Documentation("TABELA COM EMBEDDED FIELD")
@SequenceGenerator(name = "SEQ_EMBEDD", sequenceName = "SEQ_EMBEDD")
public class EntityWithEmbeddedList extends PersistableBusinessObject {

    private Long id;

    private List<EmbeddedField> embedded;

    /**
     * @return the id
     */
    @Id
    @GeneratedValue(generator = "SEQ_EMBEDD")
    @Column(name = "COD_EMBEDDED", precision = 17, nullable = false)
    @Documentation("CODIGO")
    public Long getId() {
        return this.id;
    }

    /**
     * @return the embedded
     */
    @Indexes({ @Index(suffix = "JT_0", columns = "COD_EMBEDDED"), @Index(columns = { "IDX" }, suffix = "0") })
    @CollectionOfElements
    @Alias("EMBLST")
    @JoinTable(name = "EMBEDDED_LIST", joinColumns = @JoinColumn(name = "COD_EMBEDDED", nullable = false))
    @IndexColumn(name = "IDX", nullable = false)
    @Comments({ @Comment(table = "EMBEDDED_LIST", value = "TABELA DE EMBEDDABLES LISTADOS"),
            @Comment(table = "EMBEDDED_LIST", column = "COD_EMBEDDED", value = "CODIGO DO OWNER DA LISTA"),
            @Comment(table = "EMBEDDED_LIST", column = "IDX", value = "TABELA DE EMBEDDABLES LISTADOS") })
    public List<EmbeddedField> getEmbedded() {
        return this.embedded;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param embedded the embedded to set
     */
    public void setEmbedded(List<EmbeddedField> embedded) {
        this.embedded = embedded;
    }
}
